package ManagerImage.Utils;

import javafx.scene.control.TreeItem;
import javafx.scene.image.Image;

import java.io.File;

public class DirUtil {
    private IconUtil icontool=new IconUtil();
    /**
     * 递归方法添加子目录
     * @param parentItem
     * @param directory
     */
    public void addSubDirectories(TreeItem<String> parentItem, File directory){

            File[] subDirectories = directory.listFiles(File::isDirectory);
        if (subDirectories != null) {
            for (File subDir : subDirectories) {
                TreeItem<String> subItem = new TreeItem<>(subDir.getPath());
                icontool.setIconInView_right(subItem,new Image("resource/folder.png"));
                parentItem.getChildren().add(subItem);
            }
        }
    }
}
